package com.hl.service.impl;

import com.hl.bean.OperationTwoBean;
import com.hl.dao.IOperationTwoDao;
import com.hl.pojo.Employee;
import com.hl.pojo.Sc20SceneVolumehome;
import com.hl.service.IOperationTwoService;
import com.hl.util.Pager;

public class OperationTwoServiceImpl implements IOperationTwoService {

	private IOperationTwoDao operTwoDao = null;
	
	
	public boolean delete(OperationTwoBean bean) throws Exception {
		return false;
	}

	public boolean exist(OperationTwoBean bean) throws Exception {
		StringBuffer hql = new StringBuffer("from Sc20SceneVolumehome s where s.sc20=?");
		Integer count = operTwoDao.findCount(hql.toString(), new Object[] { bean.getSc20() });
		return (count != null && count > 0) ? true : false;
	}

	
	public Pager find(OperationTwoBean bean, int curpage, int pageSize) throws Exception {
		return null;
	}

	
	public OperationTwoBean get(OperationTwoBean bean) throws Exception {
		Sc20SceneVolumehome sv = (Sc20SceneVolumehome)operTwoDao.get(Sc20SceneVolumehome.class, bean.getSc20());
		OperationTwoBean operBean = new OperationTwoBean();
		operBean.setEmployeeId(sv.getEmployee().getEmployeeId().toString());
		operBean.setVolumeDate(sv.getVolumeDate());
		operBean.setHouseType(sv.getHouseType());
		operBean.setConstructArea(sv.getConstructArea());
		operBean.setActualArea(sv.getActualArea());
		operBean.setHouseAdress(sv.getHouseAdress());
		operBean.setAmounthomeCosts(sv.getAmounthomeCosts());
		operBean.setHousePlan(sv.getHousePlan());
		operBean.setScenePlan(sv.getScenePlan());
		return operBean;
	}

	public boolean save(OperationTwoBean bean) throws Exception {
		boolean flag = true;
		try {
			Employee employee = new Employee();
			employee.setEmployeeId(Integer.parseInt(bean.getEmployeeId()));
			
			Sc20SceneVolumehome sc = new Sc20SceneVolumehome();
			sc.setEmployee(employee);
			sc.setVolumeDate(bean.getVolumeDate());
			sc.setHouseType(bean.getHouseType());
			sc.setConstructArea(bean.getConstructArea());
			sc.setActualArea(bean.getActualArea());
			sc.setHouseAdress(bean.getHouseAdress());
			sc.setAmounthomeCosts(bean.getAmounthomeCosts());
			sc.setHousePlan(bean.getHousePlan());
			sc.setScenePlan(bean.getScenePlan());
			operTwoDao.save(sc);			
		} catch (Exception e) {
			flag = false;
			throw new Exception(e);
		}
		return flag;
	}

	
	public boolean update(OperationTwoBean bean) throws Exception {
		boolean flag = true;
		try {
			System.out.println("bean.getSc20()==="+bean.getSc20());
			Sc20SceneVolumehome scsv = (Sc20SceneVolumehome) operTwoDao.get(Sc20SceneVolumehome.class, bean.getSc20());
			scsv.setVolumeDate(bean.getVolumeDate());
			scsv.setHouseType(bean.getHouseType());
			scsv.setConstructArea(bean.getConstructArea());
			scsv.setActualArea(bean.getActualArea());
			scsv.setHouseAdress(bean.getHouseAdress());
			scsv.setAmounthomeCosts(bean.getAmounthomeCosts());
			scsv.setHousePlan(bean.getHousePlan());
			scsv.setScenePlan(bean.getScenePlan());
			System.out.println("bean.getSc20()+++");
			operTwoDao.update(scsv);
		} catch (Exception e) {
			flag = false;
			throw new Exception(e);
		}
		return flag;
	}

	
	
	
	
	public IOperationTwoDao getOperTwoDao() {
		return operTwoDao;
	}

	public void setOperTwoDao(IOperationTwoDao operTwoDao) {
		this.operTwoDao = operTwoDao;
	}

	


	
	

	
}
